package stz.flash.option.flashlight;

import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FieldChangeListener;
import stz.flash.option.OptionLabel;
import stz.flash.string.OptionInformation;
import stz.flash.string.OptionString;
import blackberry.util.field.DjCheckboxField;
import blackberry.util.field.DjLabelField;


public class BacklightStartupStateCheckbox extends DjCheckboxField implements FieldChangeListener{

	public BacklightStartupStateCheckbox() {
		super(DjLabelField.createSimpleLabel(OptionString.BACKLIGHT_STARTUP_STATE_CHECKBOX_LABEL),
				OptionLabel.createInfoLabel(OptionInformation.BACKLIGHT_STARTUP_STATE_CHECKBOX_INFORMATION),
				BacklightOption.getIns().isStartupBacklightState());
		setChangeListener(this);
	}

	public void fieldChanged(Field arg0, int context) {
		if (PROGRAMMATIC == context) {
			return;
		}
		if (getChecked()) 
			setStartupBacklightState(true);
		else
			setStartupBacklightState(false);
		
	}

	private void setStartupBacklightState(boolean backlightState) {
		BacklightOption.getIns().setStartupBacklightState(backlightState);
	}
}